package yunmouren.top.kaoui.Commands;

import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import yunmouren.top.kaoui.tools.JourneyMapApi;

import java.util.Objects;

public class RegisterNavigationPoint extends CommandBase {
    @Override
    public String getName() {
        return "kaoui";
    }

    @Override
    public String getUsage(ICommandSender sender) {
        return "/kaoui";
    }

    @Override
    public int getRequiredPermissionLevel() {
        return 1;
    }

    @Override
    public void execute(MinecraftServer server, ICommandSender sender, String[] args) {
        try {
            String type = args[0];
            if (Objects.equals(type, "create")&&args[4]!=null){
                String name = args[1];
                int X = Integer.parseInt(args[2]);
                int Y = Integer.parseInt(args[3]);
                int Z = Integer.parseInt(args[4]);
                JourneyMapApi.show(name,sender.getEntityWorld().getWorldType().getId(),new BlockPos(X,Y,Z));
            }else {
                sender.sendMessage(new TextComponentString("Type is required"));
                sender.sendMessage(new TextComponentString("Create <name> < X Y Z> To Create beacon"));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
